package com.atguigu.day211103.exer;

import jdk.internal.util.xml.impl.Input;

import java.util.Scanner;
import java.util.jar.JarEntry;

public class ObjectArrayTest {
    public static void main(String[] args) {

        Student[] students = new Student[3];
        Scanner input = new Scanner(System.in);
        for (int i = 0; i < students.length; i++) {

            System.out.print("请输姓名:");
            String name = input.next();

            students[i] = new Student();
            students[i].setName(name);

            System.out.print("输入成绩:");
            int score = input.nextInt();
            students[i].setScore(score);
        }
        for (int i = 1; i < students.length; i++) {
            for (int j = 0; j < students.length - i; j++) {
                if (students[j].getScore() > students[j + 1].getScore()) {
                    Student empt = students[j];
                    students[j] = students[j + 1];
                    students[j + 1] = empt;
                }
            }
        }

        System.out.println("排序:");
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i].getInfo());
        }
    }
}